package org.javaboy.vhr.controller.carmanager;
/**
 * ClassName: CarManagerfController <br/>
 * Description: <br/>
 * date: 2020/3/21 20:47<br/>
 *
 * @author Hesion<br />
 * @version
 * @since JDK 1.8
 */

import org.javaboy.vhr.model.*;
import org.javaboy.vhr.service.CarManagerfService;
import org.javaboy.vhr.service.CarService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.Date;
import java.util.List;

/**
 * @program: vhr
 * @description:
 * @author: hesion
 * @create: 2020-03-21 20:47
 **/
@RestController
@RequestMapping("/manager/basic")
public class CarManagerfController {

    @Autowired
    CarManagerfService carManagerfService;
    @Autowired
    CarService carService;
    @GetMapping("/")
    public RespPageBean getManagerByPage(@RequestParam(defaultValue = "1") Integer page, @RequestParam(defaultValue = "10") Integer size, Manager manager, Date[] beginDateScope) {
        return carManagerfService.getManagerByPage(page, size, manager, beginDateScope);
    }

    @GetMapping("/carInfo")
    public RespPageBean getCarByPage(@RequestParam(defaultValue = "1") Integer page, @RequestParam(defaultValue = "10") Integer size, Car car, Date[] beginDateScope) {
        return carService.getCarByPage(page, size, car, beginDateScope);
    }
    /**
        *@Author hst
        *@Description //TODO 给车辆分配管理员
        *@Date 8:28 2020/3/22
        *@Param [car]
        * @return org.javaboy.vhr.model.RespBean
        **/
    @PostMapping("/CarToM")
    public RespBean mallocM(@RequestBody CarManager carManager) {
        if (carService.mallocM(carManager) == 1) {
            return RespBean.ok("分配成功!");
        }
        return RespBean.error("分配失败!");
    }

    @PostMapping("{cId}")
    public List<Manager> showCarManager(@PathVariable String cId){
        return carManagerfService.showCarManager(cId);
    }
}
